# Maintainer: Christian Hesse <mail@eworm.de>

pkgname=perl-dbd-mariadb
pkgver=1.21
pkgrel=2
pkgdesc='MariaDB and MySQL driver for the Perl5 Database Interface (DBI)'
arch=('x86_64')
license=('GPL' 'PerlArtistic')
url='https://metacpan.org/release/DBD-MariaDB'
depends=('mariadb-libs' 'perl-dbi')
makedepends=('perl-devel-checklib')
checkdepends=('mariadb' 'perl-test-deep')
source=("https://cpan.metacpan.org/authors/id/P/PA/PALI/DBD-MariaDB-${pkgver}.tar.gz")
sha512sums=('0378b33e9cd31ced6f2331967c7ea63a233340bb4a60ef2bbece4843b3a62624875aa1a5e61a9fa1b709ecc8d67810c6fa4fb9ccc01df341e6d94325078f360a')

build() {
  cd DBD-MariaDB-${pkgver}

  perl Makefile.PL INSTALLDIRS=vendor --testsocket=/tmp/socket.mysql
  make
}

check() {
  cd DBD-MariaDB-${pkgver}

  mkdir -p /tmp/mysql_test
  mariadb-install-db \
     --basedir=/usr \
     --datadir=/tmp/mysql_test
  mariadbd -P 17999 \
     --socket=/tmp/socket.mysql \
     --datadir=/tmp/mysql_test &
  sleep 10
  DAEMON_PORT=$!
  make test
  kill -9 $DAEMON_PORT
}

package() {
  cd DBD-MariaDB-${pkgver}

  make install DESTDIR="${pkgdir}"
}
